<?php
/**
 * XmuSlh, web platform of Student Association Federation of Xiamen University
 * 
 * Rewritting one or some pages of StatusNet. 
 * To get the original version, please visit <http://status.net/>.
 * 
 * StatusNet, the distributed open-source microblogging tool
 * 
 * LICENCE: This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

/**
 * Base class for star mark box.
 * 
 * 用来显示一个评级控件.
 * MUST include the 'jRating' js libaray.
 * 
 * @author		ytukie <ytukie@gmail.com>
 * @version		0.2
 * 
 * 0.2)  Css modified.
 */

// XmuSlh only.
if ( !defined('XMUSLH')) { exit(1); }

// Requirements.
require_once INSTALLDIR . '/lib/slh_widget.php';
require_once INSTALLDIR . '/lib/slh_util.php';


/**
 * Widget for displaying mark star.
 */
class MarkStar extends Widget
{
	/**
	 * User id.
	 */
	var $user_id;
	
	/**
	 * Average mark.
	 */
	var $average;
	
	/**
	 * Constructor.
	 */
	function __construct($user_id,
						 $out = null)
	{
		parent::__construct($out);

		$this->user_id = $user_id;
		$this->average = Association_Mark::getAverage($this->user_id);
	}
	
	/**
	 * Show the mark star.
	 */
	function show()
	{
		$this->out->elementStart('div', 'cls_div_mark');
		
		$this->out->hidden('mark_starsurl', slh_full_path('theme/base/jRating/stars.png'));
		$this->out->hidden('mark_markjsonaction', slh_action2url('markjson'));
		$this->out->hidden('mark_user_id', $this->user_id);
		$this->out->hidden('mark_average', $this->average);
		
		$this->out->elementStart('div', array('class' => 'markstar'));
		$this->out->elementEnd('div');
		$this->out->element('div', array('class' => 'marktips'));
		$this->out->elementEnd('div');
	}
	
}

?>